package com.example.dogliving.fragment.column;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.dogliving.R;
import com.example.dogliving.bean.ColumnBean;
import com.example.dogliving.helper.RecyclerViewAdapterHelper;

import java.util.List;

/**
 * Created by 张博文 on 2016/12/27.
 */

public class ColumnAdapter extends RecyclerViewAdapterHelper{
    private Context mContext;
    private List<ColumnBean.DataListBean> mList;
    private RecyclerView recyclerView;
//传参
    public ColumnAdapter(Context context, List list , RecyclerView recyclerView) {
        super(context, list);
        this.mContext=context;
        this.mList=list;
        this.recyclerView=recyclerView;
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        //加载页面
        View view=mInflater.inflate(R.layout.item_fragment_column,parent,false);
        return new MyHolder(view);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof MyHolder){
            //加载数据
            ((MyHolder) holder).tv_item_column_top.setText(mList.get(position).getName());
            ((MyHolder) holder).tv_item_column_bottom.setText(mList.get(position).getLivenum()+"个直播");
            Glide.with(mContext).load(mList.get(position).getImgurl()).into(((MyHolder) holder).iv_item_column);
        }

    }

    private class MyHolder extends RecyclerView.ViewHolder {
        private ImageView iv_item_column;
        private TextView tv_item_column_top,tv_item_column_bottom;
        public MyHolder(View view) {
            super(view);
            iv_item_column= (ImageView) view.findViewById(R.id.iv_item_column);
            tv_item_column_top= (TextView) view.findViewById(R.id.tv_item_column_top);
            tv_item_column_bottom= (TextView) view.findViewById(R.id.tv_item_column_bottom);
        }
    }
}
